package com.fuluwa.domain.order.model;

import java.util.Set;

import com.fuluwa.infra.exception.PersistenceException;

public class OrderFactory {

	/**
	 * Create a order, saved.
	 * @param seller
	 * @param remark
	 * @param payType
	 * @param items
	 * @return
	 * @throws PersistenceException
	 */
	public static Order createNewOrder(String seller, String remark, PayType payType, Set<OrderItem> items)
			throws PersistenceException {
		PaymentInfo pay = new PaymentInfo(payType);
		Order order = new Order(seller, pay, remark);
		order.addItem(items);
		order.save();
		pay.save();
		return order;
	}
}
